#include"game.h"

//文件名叫做 tcpSend.c 更好吧

/**
 * @brief TCP发送线程
 * 
 * @param arg 
 * @return void* 
 */
void* tcp_send(void* arg)//为什么没有tcp_rcv线程呢？？
{
    while(1)
    {
        int touch_x;
        int touch_y;
        int touch_ret;
        tcp_client_data send_data;
        while (1)
        {
            //获取玩家点击位置
            getLoca(NULL,&touch_x,&touch_y,NULL,NULL);
            //设置贪吃蛇控制方向键
            touch_ret = touchModule(touch_x,touch_y,500,300,780,460,3,2);
            if(touch_ret==-1)
            {
                //判断退出键是否被点击
                if(touch_simgle_region(touch_x,touch_y,660,20,780,110)==BETOUCH)
                {
                    gameOver = 1;
                    send_data.command = EXIT_GAME;//send_data是一个结构体，结构体是如何定义的呢？？？
                }
            }
            //判断点击的方向键
            if(touch_ret==2)
            {
                send_data.direc = UP;
                printf("UP");
                break;
            }
            else if(touch_ret==4)
            {
                send_data.direc = LEFT;
                printf("LEFT");
                break;
            }
            else if(touch_ret==5)
            {
                send_data.direc = DOWN;
                printf("DOWN");
                break;
            }
            else if(touch_ret==6)
            {
                send_data.direc = RIGHT;
                printf("RIGHT");
                break;
            }
            
        }
        send_data.command = 123123;//这串命令有什么意义呢？？？
        send(*(int*)arg,&send_data,sizeof(tcp_client_data), 0);
    }
}